home *** CD-ROM | disk | FTP | other *** search
/ Geek Games #12 / GEGA012.iso / Jogos de Azar / 1721-apuesten.swf / scripts / C_ChipsCLASS.as < prev    next >
Text File  |  2006-01-17  |  5KB  |  181 lines

  1. _global.C_ChipsCLASS = function()
  2. {
  3.    if(this.child_flag)
  4.    {
  5.       return undefined;
  6.    }
  7.    this.chipDepth = ++this.__proto__.chipsCounter + this.__proto__.globalChipDepth;
  8.    this.stop();
  9.    if(this.bet > 0)
  10.    {
  11.       this.setBet(this.bet);
  12.    }
  13. };
  14. C_ChipsCLASS.prototype = new MovieClip();
  15. C_ChipsCLASS.prototype.chipsCounter = 0;
  16. C_ChipsCLASS.prototype.globalChipDepth = 1500;
  17. C_ChipsCLASS.prototype.multyLine = false;
  18. C_ChipsCLASS.prototype.ChNominals = new Array(1000,500,100,25,5,1,0.5);
  19. C_ChipsCLASS.prototype.Chwh = 40;
  20. C_ChipsCLASS.prototype.scaleParam = 100;
  21. C_ChipsCLASS.prototype.topSymbol = "chip_OFF";
  22. C_ChipsCLASS.prototype.createPlace = function(noEffects)
  23. {
  24.    if(!this.place)
  25.    {
  26.       this.place = this.duplicateMovieClip(this._name + "_New",this.chipDepth);
  27.       this.place.swapDepths(this);
  28.       this.place.child_flag = true;
  29.    }
  30.    else
  31.    {
  32.       this.place.gotoAndStop(1);
  33.       this.place.Targ.removeMovieClip();
  34.       this.place.topMC.removeMovieClip();
  35.       this.place.copy(this);
  36.    }
  37.    if(!noEffects)
  38.    {
  39.       this.place._br = this.place._brightness = 50;
  40.       this.place.onEnterFrame = function()
  41.       {
  42.          this._br -= 10;
  43.          this._brightness = this._br;
  44.          if(this._br <= 0)
  45.          {
  46.             this.place._brightness = 0;
  47.             delete this.place._br;
  48.             delete this.onEnterFrame;
  49.          }
  50.       };
  51.    }
  52.    this.place._xscale = this.place._yscale = this.scaleParam;
  53.    this.place.Targ_MC.duplicateMovieClip("Targ",10);
  54.    this.place.Targ_MC.duplicateMovieClip("topMC",20);
  55.    this.place.play();
  56. };
  57. C_ChipsCLASS.prototype.createTop = function(libraryId)
  58. {
  59.    if(libraryId == undefined)
  60.    {
  61.       libraryId = this.topSymbol;
  62.    }
  63.    if(!this.place)
  64.    {
  65.       this.setBet(this.bet);
  66.    }
  67.    var o = this.place.topMC;
  68.    o.lib.removeMovieClip();
  69.    o.createEmptyMovieClip("lib",1000);
  70.    o.lib.creatSqv("tmp",123,1,0,true);
  71.    o.lib.align(this.lastChip);
  72.    o.lib.tmp.removeMovieClip();
  73.    o.lib.attachMovie(libraryId,"topSymbol",1000);
  74.    o.lib.movieBy(0,-3);
  75. };
  76. C_ChipsCLASS.prototype.clearTop = function()
  77. {
  78.    this.createTop("");
  79. };
  80. C_ChipsCLASS.prototype.setBet = function(bet, m, noSound)
  81. {
  82.    if(noSound == undefined && bet == 0)
  83.    {
  84.       noSound = true;
  85.    }
  86.    this.createPlace(noSound);
  87.    if(m != undefined)
  88.    {
  89.       this.multyLine = m;
  90.    }
  91.    this.bet = Number(bet);
  92.    var CashChips = this.bet;
  93.    var ChArray = new Array();
  94.    var n = 0;
  95.    var i = 0;
  96.    while(i < this.ChNominals.length)
  97.    {
  98.       if(CashChips >= this.ChNominals[i])
  99.       {
  100.          var cRem = CashChips;
  101.          CashChips %= this.ChNominals[i];
  102.          ChArray[n] = new Array();
  103.          ChArray[n][0] = (cRem - CashChips) / this.ChNominals[i];
  104.          ChArray[n][1] = "chip_" + this.ChNominals[i];
  105.          if(this.ChNominals[i] == 0.5)
  106.          {
  107.             ChArray[n][1] = "chip_05";
  108.          }
  109.          n++;
  110.       }
  111.       i++;
  112.    }
  113.    if(!this.multyLine)
  114.    {
  115.       var xPos = 0;
  116.       var yPos = 0;
  117.       var i = 0;
  118.       while(i < ChArray.length)
  119.       {
  120.          var n = 0;
  121.          while(n < ChArray[i][0])
  122.          {
  123.             var newChip = this.place.Targ.attachMovie(ChArray[i][1],ChArray[i][1] + "_" + (n + 1),d++);
  124.             newChip.movieTo(xPos,yPos);
  125.             yPos -= 3;
  126.             n++;
  127.          }
  128.          xPos += 1;
  129.          i++;
  130.       }
  131.    }
  132.    else
  133.    {
  134.       var d = 12;
  135.       var dSh = 0;
  136.       var c = 0;
  137.       var b = 0;
  138.       var i = 0;
  139.       while(i < ChArray.length)
  140.       {
  141.          var n = 0;
  142.          while(n < ChArray[i][0])
  143.          {
  144.             var newChip = this.place.Targ.attachMovie(ChArray[i][1],ChArray[i][1] + "_" + (n + 1),d++);
  145.             c = Math.floor(n / this.Chwh);
  146.             newChip.movieTo((i + b + c) * 17,- (n - c * this.Chwh) * 3);
  147.             n++;
  148.          }
  149.          this.place.Targ.attachMovie("chip_shadow","chip_shadow" + dSh,dSh++);
  150.          this.place.Targ["chip_shadow" + (dSh - 1)]._x = newChip._x;
  151.          b += c;
  152.          i++;
  153.       }
  154.    }
  155.    this.lastChip = newChip;
  156.    this.place.Targ.alignH();
  157.    if(!this.noSound && !noSound)
  158.    {
  159.       this.place.newSound("chip");
  160.    }
  161.    if(!this.multyLine && this.bet > 0)
  162.    {
  163.       this.place.Targ.attachMovie("chip_shadow","chip_shadow",-1).moveBy(5,-5);
  164.    }
  165.    return this.place;
  166. };
  167. C_ChipsCLASS.prototype.getPlace = function()
  168. {
  169.    return this.place;
  170. };
  171. _global.makeChips = function(targMC, CashChips, multyLine)
  172. {
  173.    if(multyLine != null)
  174.    {
  175.       targMC.multyLine = multyLine;
  176.    }
  177.    return targMC.setBet(CashChips);
  178. };
  179. Object.registerClass("C_ChipsCLASS",C_ChipsCLASS);
  180. ASSetPropFlags(_global,"C_ChipsCLASS,makeChips",131);
  181.